package com.ccl.iot.huiju;


import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.ccl.iot.R;
import com.ccl.iot.fragments.dialog.BaseDialogFragment;


public class MessageDialogFragment extends BaseDialogFragment {


    private Button mOKBtn;
    private Button mCannelBtn;
    private TextView mMsgTv;
    private String mMessage;

    public OnOKClickListener mOnOKClickListener;

    public interface OnOKClickListener{
        void onOKEvent();
    }

    public MessageDialogFragment() {
        // Required empty public constructor
    }

    public static MessageDialogFragment newInstance() {
        MessageDialogFragment fragment = new MessageDialogFragment();
        return fragment;
    }


    @Override
    public View BindContentView(LayoutInflater localInflater, ViewGroup container) {
        return localInflater.inflate(R.layout.dialog_remove_iothuiju, container, false);
    }

    @Override
    public void initView(View view) {

        mMsgTv = (TextView) view.findViewById(R.id.tv_name);
        mMsgTv.setText(mMessage);

        mOKBtn = (Button) view.findViewById(R.id.btn_ok);
        mCannelBtn = (Button) view.findViewById(R.id.btn_cancel);
        mOKBtn.setText(R.string.OK);

    }


    public void setMessage(String msg,OnOKClickListener listener){
        mOnOKClickListener = listener;
        mMessage = msg;
        if (mMsgTv != null){
            mMsgTv.setText(msg);
        }
    }

    @Override
    public void initListeners() {


        mOKBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                dismiss();

                if (mOnOKClickListener != null){
                    mOnOKClickListener.onOKEvent();
                }

            }
        });

        mCannelBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

    }

    @Override
    public void initData() {


    }




}
